package cn.lizemin.demo.thread.timed_waiting;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class MyThread extends Thread{
    //这是一个main方法,是程序的入口
    public static void main(String[] args) throws InterruptedException {
        MyThread mt = new MyThread();
        mt.start();
        for (int i = 0; i < 10; i++) {
            Thread.sleep(500);
            System.out.println("线程mt的状态为："+mt.getState());
        }
    }
    //实现一个计数器，0~99计数，在每个数字之间暂停1秒，每隔10个数字输出一个字符串
    @Override
    public void run() {
        for (int i = 1; i < 99; i++) {
            if (i % 10 == 0){
                System.out.println("小猫爱吃鱼"+i);
            }
            System.out.println(i);
            try {
                /*休息1s*/
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        for (int i = 1; i < 99; i++) {


        }
    }
}
